{extend name="base" /}
{block name="title"}
<title>入园咨询</title>
{/block}
{block name="content"}

<fieldset class="layui-elem-field layui-field-title">
    <legend>
        <span class="layui-breadcrumb">
            <a><cite>入园咨询管理</cite></a>
        </span>
    </legend>
    <br>
    <!--<a href="{:url('admin/lunbo/add', ['type' => request()->route('type')])}" class="layui-btn">添加入园咨询</a>
    <a href="{:url('admin/lunbo/index', ['type' => request()->route('type')])}" class="layui-btn layui-btn-normal" target="">入园咨询列表</a>-->
</fieldset>
<!--<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
    <legend>方框风格的表单集合</legend>
</fieldset>-->

<form class="layui-form layui-form-pane" action="" method="post">
    <table class="layui-table">
        <colayui-inputroup>
            <col width="10%">
            <col width="60%">
            <col width="20%">
        </colayui-inputroup>
        <thead>
        <tr>
            <th class="tc">名称</th>
            <th class="tc">输入内容</th>
            <th class="tc">描述</th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <th><i class="require"></i>标题：</th>
            <td>
                <input type="text" class="layui-input" name="title" placeholder="这里输入内容" value="{$data.title}">
                <span></span>
            </td>
            <td></td>
        </tr>
        <tr align="center">
            <td  align="center" colspan="3" style="height: 40px;"><b>1.内容区块管理</b></td>
        </tr>
        <tr>
            <th><i class="require"></i>小标题1：</th>
            <td>
                <input type="text" class="layui-input" name="title1" placeholder="这里输入内容" value="{$data.title1}">
                <span></span>
            </td>
            <td></td>
        </tr>

        <tr>
            <th><i class="require"></i>内容1：</th>
            <td>
                <textarea class="layui-textarea" name="content1">{$data.content1}</textarea>
            </td>
            <td></td>
        </tr>
        <tr align="center">
            <td  align="center" colspan="3" style="height: 40px;"><b>2.内容区块管理</b></td>
        </tr>
        <tr>
            <th><i class="require"></i>小标题2：</th>
            <td>
                <input type="text" class="layui-input" name="title2" placeholder="这里输入内容" value="{$data.title2}">
                <span></span>
            </td>
            <td></td>
        </tr>
        <tr>
            <th><i class="require"></i>内容2：</th>
            <td>
                <textarea class="layui-textarea" name="content2">{$data.content2}</textarea>
            </td>
            <td></td>
        </tr>
        <tr>
            <th><i class="require"></i>内容2链接名称：</th>
            <td>
                <input type="text" class="layui-input" name="href_name" placeholder="这里输入内容" value="{$data.href_name}">
            </td>
            <td></td>
        </tr>

        <tr align="center">
            <td  align="center" colspan="3" style="height: 40px;"><b>3.内容区块管理</b></td>
        </tr>
        <tr>
            <th><i class="require"></i>小标题3：</th>
            <td>
                <input type="text" class="layui-input" name="title3" placeholder="这里输入内容" value="{$data.title3}">
                <span></span>
            </td>
            <td></td>
        </tr>
        <tr>
            <th><i class="require"></i>内容3：</th>
            <td>
                <textarea class="layui-textarea" name="content3">{$data.content3}</textarea>
            </td>
            <td></td>
        </tr>

        <tr align="center">
            <td  align="center" colspan="3" style="height: 40px;"><b>4.内容区块管理</b></td>
        </tr>
        <tr>
            <th><i class="require"></i>小标题4：</th>
            <td>
                <input type="text" class="layui-input" name="title4" placeholder="这里输入内容" value="{$data.title4}">
                <span></span>
            </td>
            <td></td>
        </tr>
        <tr>
            <td class="tc" width="10px"><i class="require">*</i>图片上传：</td>
            <td>
                <div class="site-demo-upload" style="background-color: #834c92">
                    <img id="LAY_demo_upload" src="{$data.img_url}" width="373px" height="280px">
                    <div class="site-demo-upbar">
                        <input type="file" name="file" class="layui-upload-file" id="test">
                    </div>
                </div>
                <input id="img_url" class="layui-input" type="hidden" name="img_url" value="{$data.img_url}">
            </td>
            <td>入园图片，请使用FTP替换原图，此处只是列出文字图片上传。</td>
        </tr>

        <tr align="center">
            <td  align="center" colspan="3" style="height: 40px;"><b>5.地图区块管理</b></td>
        </tr>
        <tr>
            <th><i class="require"></i>小标题5：</th>
            <td>
                <input type="text" class="layui-input" name="title5" placeholder="这里输入内容" value="{$data.title5}">
                <span></span>
            </td>
            <td></td>
        </tr>

        <tr>
            <td colspan="2">
                <div class="layui-form-item">
                    <!--<button class="layui-btn" lay-submit="" lay-filter="sub">提交</button>-->
                    <input type="submit" class="layui-btn" value="提交">
                </div>
            </td>
            <td></td>
        </tr>
        </tbody>
    </table>
</form>
{/block}
{block name="js"}
<script type="text/javascript">
    layui.use(['form', 'layedit', 'laydate','element','upload'], function () {
        var form = layui.form(), layer = layui.layer, layedit = layui.layedit, laydate = layui.laydate,element = layui.element;

        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');

        //自定义验证规则
        form.verify({
            name: function (value) {
                if (value.length < 2) {
                    return '标题至少得2个字符啊';
                }
            }
            , pass: [/(.+){6,12}$/, '密码必须6到12位']
            , content: function (value) {
                layedit.sync(editIndex);
            }
        });

        //监听提交
        form.on('submit(sub)', function (data) {
            /*layer.alert(JSON.stringify(data.field), {
             title: '最终的提交信息'
             });*/
            return true;
        });

        // you code ...
        layui.upload({
            url: '{:url("/admin/common/upload/type/lunbo")}'
            ,elem: '#test' //指定原始元素，默认直接查找class="layui-upload-file"
            ,method: 'post' //上传接口的http类型
            ,success: function(datap){
                //var datap = JSON.parse(data); //$.parseJSON(data);
                layer.msg(datap.msg);
                if(datap.errno == 0) {
                    /*$("input[name='img_url']").val(datap.path);
                     $('#img_url_img').attr('src', datap.path);*/
                    LAY_demo_upload.src = datap.path;
                    img_url.value = datap.path;
                }
            }
        });
    });
</script>
{/block}